<template>
  <div class="app-container">
    <div class="assn-img">
      <img :src="photo" alt="">
    </div>
    <div class="container">
      <div class="title">
        <span>{{name}}</span>
      </div>
      <div>
        <textarea class="content" v-model="content" name="" id="" cols="30" rows="10"></textarea>
      </div>
      <div class="btn-group">
      <button class=" btn change-btn" @click="change">確定</button>
      <button class="btn reset-btn" @click="$router.go(-1)">取消</button>
    </div>
    </div>
  </div>
</template>

<script>
import { getSocietyInfo, isManager } from '@/api/society'
import { isLogin, isBind } from '@/api/login'
export default {
  name: 'Summary',
  data () {
    return {
      photo: '',
      name: '1212',
      content: '',
      sid: this.$route.query.sid
    }
  },
  created () {
    // this.isManager()
    this.loadList()
  },
  methods: {
    loadList () {
      getSocietyInfo({
        sid: this.sid
      }).then(res => {
        var resData = res.data
        this.name = resData.society.name
        this.content = resData.society.content
        this.photo = 'http://weyouth.vip' + resData.society.cover
      }).catch(err => {
        console.log(err)
      })
    },
    isManager () {
      isLogin().then(res => {
        if (res.code === 0) {
          this.$router.push('/')
        } else if (res.code === 1) {
          isBind().then(res => {
            if (res.code === 0) {
              this.$router.push('/wx_bind')
            } else if (res.code === 1) {
              localStorage.setItem('isLogin', 'isLogin')
              isManager({
                sid: this.sid
              }).then(res => {
                if (res.code === 1) {
                  this.$router.push('/manage_society?sid=' + this.sid)
                } else {
                  alert('您沒有管理權限')
                }
              }).catch(err => { console.log(err) })
            }
          }).catch(err => { console.log(err) })
        }
      }).catch(err => { console.log(err) })
    },
    change () {

    }
  }
}
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
}
.app-container {
  height: 700px;
  background: #fff;
  width: 100%;
  /* padding: 5px; */
  text-align: center;
}
.container {
  margin-top: 20px;
  text-align: center;
}
.title {
  height: 28px;
  text-align: left;
  width: 80%;
  margin-left: 5%;
}
.content {
  width: 90%;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 5px;
}
.assn-img {
  width: 100%;
  height: 174px;
  /* border: 1px solid #000; */
}
.assn-img img {
  display: inline-block;
  width: 100%;
  height: inherit;
}
.btn-group {
  width: 100%;
  margin-top: 10%;
  padding: 20px;
  text-align: start;
}
.btn {
  width: 129px;
  height: 46px;
  opacity:0.8;
  border-radius:10px;
  border: none;
  color: #fff;
  font-size: 14px;
  text-align: center;
}
.change-btn {
  margin-left: 20px;
  background: rgb(249, 119, 130);
  background:linear-gradient(93deg,rgba(240,84,73,1) 0%,rgba(240,89,67,1) 18%,rgba(237,56,99,1) 55%,rgba(238,57,98,1) 64%,rgba(237,56,99,1) 100%);
}
.reset-btn {
  background: #ccc;
  float: right;
  margin-right: 20px;
}
</style>
